<?php
namespace app\admin\controller;

class Auth extends Base{
	public function __construct()
	{
		parent::__construct();
	}
	/**
	 *  权限
	 */
    function _initialize() {
		
		if(in_array((int)session("id"),C("ADMINISTRATOR")) || false == session('user') || time()-session('lastAct')>C('login_timeout')){
			return true;
			}else{
			$auth = new \org\Auth();
			$check = $auth->check(MODULE_NAME."/".CONTROLLER_NAME."/".ACTION_NAME,session('id'));	
			if(!$check){
				if(null ===session('id')){
					exit($this->error('没有权限', U('Sign/in'))); 
				}else{
					exit($this->error('没有权限', U('Index/index'))); 
				}
				
				}
			}
			
			

	}
	
	    protected function isLogin()
    {

        if(false == session('user') || time()-session('lastAct')>C('login_timeout')){
            $this->redirect('Sign/in');
            exit();
        }
        session('lastAct', time());
    }

	//验证 END
	
	
}
